package cn.jiyun.user.controller;

import cn.jiyun.user.pojo.User;
import cn.jiyun.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 根据id查询用户
     */
    @GetMapping("/findById/{id}")
    public User findById(@PathVariable("id") Long id){
        User user = userService.findById(id);
        return user;
    }

    /**
     * 测试局部过滤器使用
     * @param name
     * @return
     */
    @GetMapping("/findName")
    public String findName(@RequestParam(defaultValue = "zhangsan") String name){

        return "用户名是："+name;
    }


}
